package teacher;
import java.io.*;
public class XmlLab1
{
	public static void main(String[] args){
	   User user = new User("Jack","male",90,182,200);
	   FileWriter writer = null;
	   PrintWriter out = null;
	   try{
	      writer = new FileWriter("user.xml");
		  out = new PrintWriter(writer);
          StringBuffer sb = new StringBuffer();
		  sb.append("<?xml version=\"1.0\" ?>\n");
		  sb.append("<users>\n");
		  sb.append("  <user>\n");
		  sb.append("    <name>"+user.getName()+"</name>\n");
          sb.append("    <gender>"+user.getGender()+"</gender>\n");
          sb.append("    <age>"+user.getAge()+"</age>\n");
          sb.append("    <height>"+user.getHeight()+"</height>\n");
          sb.append("    <weight>"+user.getWeight()+"</weight>\n");
          sb.append("  </user>\n");
		  sb.append("</users>");
		  out.print(sb.toString());
	   }catch(Exception e){
	      e.printStackTrace();
	   }finally{
		  try{out.close();}catch(Exception ex){ex.printStackTrace();}
	      try{writer.close();}catch(Exception ex){ex.printStackTrace();}
		  
	   }
	}
}